<template>
	<view class="main">
		<u-search bgColor="#fff" :showAction="false" placeholder="输入所属企业号" v-model="merge_keyword"
			@change="change"></u-search>
		<view class="list flex align between" v-for="(item,index) in list" :key="index">
			<image src="../../../static/head.png"></image>
			<view class="infos">
				<view>{{item.qiyeuser.nickname}}</view>
				<view>客户昵称:{{item.nickname}}</view>
				<view>首次互动：{{item.addtime}}</view>
			</view>
			<uni-icons type="trash" size="20" color="#D81E06"></uni-icons>
		</view>
		<uni-load-more :status="status" v-if="!empty" :content-text="loadText"></uni-load-more>
		<xw-empty :isShow="empty" text="暂无数据" textColor="#777777"></xw-empty>
	</view>
</template>

<script>
	import {
		qiyeIntentionIndex,
		rankDel
	} from '@/api/apiData.js';
	export default {
		data() {
			return {
				totalPage: 1,
				page: 0,
				offset: 20,
				list: [],
				scrollTop: 0,
				empty: false,
				loadText: {
					loadmore: '点击或上拉加载更多',
					loading: '努力加载中',
					nomore: '实在没有了'
				},
				status: 'loadmore',
				merge_keyword: '',
			};
		},
		onLoad() {
			this.getlist()
		},
		onPageScroll(e) {
			const that = this;
			that.scrollTop = e.scrollTop;
		},
		onReachBottom() {
			const that = this;
			that.getlist();
		},
		methods:{
			change() {
				this.page = 0
				this.list = []
				this.getlist()
			},
			async getlist() {
				const that = this;
				const {
					totalPage,
					page,
					offset,
					list,
					group_id,
					type,
					merge_keyword,
					statusA,
					rank_id
				} = that;
			
				let obj = {
					menu_url: 'qiye_intention',
					limit: offset,
					offset: page,
					sort: 'id',
					order: 'desc',
					_: new Date().getTime(),
					filter: {},
					op: {}
					// filter:merge_keyword=='',
					// op:encodeURIComponent(JSON.stringify(filter))
				};
				if (merge_keyword != '') {
					obj.filter = JSON.stringify({
						"qiyeuser.nickname": merge_keyword.toString()
					})
					obj.op = JSON.stringify({
						"qiyeuser.nickname": 'LIKE'
					})
				}
				that.status = 'loading';
				if (totalPage > page) {
					let result = await qiyeIntentionIndex(obj);
					that.page = page + 1;
					if (result.total == 0) {
						that.empty = true;
						that.status = 'nomore';
						return;
					}
					that.empty = false;
					setTimeout(() => {
						that.status = 'loadmore';
					}, 500);
					that.list = list.concat(result.rows);
					that.totalPage = Math.ceil(result.total / offset);
				} else {
					setTimeout(() => {
						that.status = 'nomore';
					}, 500);
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.main {
		padding: 13rpx 30rpx;

		.list {
			background: white;
			border-radius: 10rpx;
			padding: 23rpx 30rpx;
			margin-top: 20rpx;

			image {
				width: 143.57rpx;
				height: 143.57rpx;
				border-radius: 50%;
				object-fit: cover;
			}

			.infos {
				font-size: 20rpx;
				color: #424242;
				width: 60%;

				view:nth-child(1) {
					font-weight: bold;
					font-size: 32rpx;
					margin-bottom: 5rpx;
				}
			}
		}
	}
</style>